#!/bin/bash

rpmdownload_tmp_dir=/lkp/$os/$os_version/$os_arch/rpm
epkg_translate_home=$LKP_SRC/programs/epkg_translate/

init_epkg_tools(){
    # 安装epkg工具
    wget https://repo.oepkgs.net/openeuler/epkg/rootfs/epkg-installer.sh
    chmod -R +x .
    yes 1| sh epkg-installer.sh
}

init_environment(){
    cd /lkp
    git clone https://gitee.com/openeuler/epkg
    cd epkg
    git checkout tag-rpm2epkg
    # install epkg-tools
    init_epkg_tools
}

parse_job(){
    rpm_baseurl=$rpm_baseurl
    os_arch=$os_arch
    translate_strategy=$translate_strategy
    # 下载转换rpm包
    cd $epkg_translate_home
    echo "python3 rpm_down.py -rpm_url $rpm_baseurl -arch $os_arch \
    -strategy $translate_strategy -tmp_dir $rpmdownload_tmp_dir"
    python3 rpm_down.py -rpm_url $rpm_baseurl -arch $os_arch \
    -strategy $translate_strategy -tmp_dir $rpmdownload_tmp_dir
}

init_environment
parse_job
